home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip0493.zip / CTRLPRNT.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  807b  |  41 lines

  1. /*
  2. **  Print a line of text, displaying Ctrl characters using leading carets
  3. **  public domain by Bob Stout
  4. */
  5.  
  6. void ctrl_print(char *line)
  7. {
  8.       while (*line)
  9.       {
  10.             if (' ' > *line)
  11.             {
  12.                   putchar('^');
  13.                   putchar('@' + (*line++));
  14.             }
  15.             else  putchar(*line++);
  16.       }
  17.       if (!strcmp((line - 2), "\x0d\x0a") || !strcmp((line - 2), "\x0a\x0d"))
  18.             putchar('\n');
  19. }
  20.  
  21. #ifdef TEST
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include <ctype.h>
  27.  
  28. void main(void)
  29. {
  30.       char *p, *test = "This is a test";
  31.  
  32.       for (p = strupr(test); *p; ++p)
  33.       {
  34.             if (isalpha(*p))
  35.                   *p = *p - 64;
  36.       }
  37.       ctrl_print(test);
  38. }
  39.  
  40. #endif /* TEST */
  41.